package com.sykj.seaflow.warm.core.config;

import cn.hutool.extra.spring.SpringUtil;
import com.sykj.seaflow.warm.core.expression.*;
import com.sykj.seaflow.warm.core.replace.WarmTaskServiceImpl;
import com.warm.flow.core.dao.FlowTaskDao;
import com.warm.flow.core.invoker.FrameInvoker;
import com.warm.flow.core.orm.service.IWarmService;
import com.warm.flow.core.orm.service.impl.WarmServiceImpl;
import com.warm.flow.core.service.TaskService;
import com.warm.flow.core.service.impl.TaskServiceImpl;
import com.warm.flow.core.utils.ExpressionUtil;
import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;

import java.util.function.Consumer;
import java.util.function.Supplier;

@Configuration
public class WarmFlowConfig implements InitializingBean {

//    @Bean
//    @Primary
//    public TaskService taskService2(FlowTaskDao taskDao) {
//        System.out.println(12333);
//        // 试一下
//        return new WarmTaskServiceImpl().setDao(taskDao);
////        return FrameInvoker.getBean(TaskServiceImpl.class).setDao(taskDao);
//    }

    /**
     * 自定义填充 （可配置文件注入，也可用@Bean/@Component方式）
     */
//    @Bean
//    public DataFillHandler dataFillHandler() {
//        return new CustomDataFillHandler();
//    }

    /**
     * mybatis plus 注入了
     * 全局租户处理器（可配置文件注入，也可用@Bean/@Component方式）
     */
//    @Bean
//    public TenantHandler tenantHandler() {
//        return new CustomTenantHandler();
//    }


    @Override
    public void afterPropertiesSet() throws Exception {
        ExpressionStrategySimpleAnd expressionStrategySimpleAnd = new ExpressionStrategySimpleAnd();
        ExpressionStrategySimpleOr expressionStrategySimpleOr = new ExpressionStrategySimpleOr();
        ExpressionStrategyDefault expressionStrategyDefault = new ExpressionStrategyDefault();
        ExpressionStrategyReject expressionStrategyReject = new ExpressionStrategyReject();
        ExpressionStrategyPass expressionStrategyPass = new ExpressionStrategyPass();
        ExpressionUtil.setExpression(expressionStrategySimpleAnd);
        ExpressionUtil.setExpression(expressionStrategySimpleOr);
        ExpressionUtil.setExpression(expressionStrategyDefault);
        ExpressionUtil.setExpression(expressionStrategyReject);
        ExpressionUtil.setExpression(expressionStrategyPass);
    }
}
